import { ClassName, FontFamily } from "./Constants";
import Img from "./features/basic-shape/Img";
import Line from "./features/basic-shape/Line";
import Link from "./features/basic-shape/link/Link";
import Text from "./features/basic-shape/Text";
import Feature from "./features/Feature";
import Group from "./features/function-shape/Group";

interface IPoint {
    x: number,
    y: number,
    generated?: boolean
}

interface IRelativePos {
    x: number,
    y: number,
    generated?: boolean
}

interface IPixelPos {
    x: number,
    y: number,
    generated?: boolean
}

interface IGridPos {
    x: number,
    y: number,
    generated?: boolean
}

interface IAdsorbPos {
    x: number,  // 吸附点
    y: number,
    // 非全屏吸附线使用
    x1?: number,  // 起点
    y1?: number,
    x2?: number,  // 终点
    y2?: number,
}

interface ISize {
    width: number,
    height: number,
}

interface IVctor {
    0: number,
    1: number
}

interface ITxt {
    content: string,
    fontSize: number,
    color: string,
    fontFamily: FontFamily,
    offset: IPoint,
    lineHeight?: number,
    fontWeight?: number,
    bolder: boolean,
    strokeWidth?: number,
    strokeColor?: string,
    autoRotate?: boolean,
    fill?: string,
    fillPadding?: number,
}

interface IArrow {
    width: number,
    height: number,
    angle: number,
    color: string,
    lineWidth: number,
    fill: string,
}

type IProps = Partial<Feature & Text & Img & Link & Group & Line> & {
    id: string,
    className: ClassName,
    style: string,
    children: IProps[],
    [key: string]: any,
}

interface Listeners {
    [key: string]: Function[]
}

interface NearNode {
    x: number,  // 坐标,以网格为单元的值
    y: number,
    name?: string,
    g?: number,  // 当前点与附近点的距离,写死
    h?: number,  // 当前点与终点水平垂直方向距离之和
    f?: number // g+h之和
}

interface Itree {
    label: string,
    children: Itree[],
    x?: number,
    y?: number,
    width?: number,
    height?: number,
}

interface Style {
    lineWidth?: number,
    color?: string,
    lineDashArr?: number[],  // 虚线
}

export type { IPoint, IRelativePos, IPixelPos, IGridPos, ISize, IVctor, ITxt, IArrow, IProps, Feature, Listeners, NearNode, Itree, IAdsorbPos, Style };